package org.zhxy.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.sql.ResultSet;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result implements Serializable {

    private boolean success;//是否成功
    private Integer code;// 返回码
    private String message;//返回信息
    private Object data;// 返回数据

    public Result(ResultCode code) {
        this.success = code.success;
        this.code = code.code;
        this.message = code.message;
    }

    public Result(ResultCode code,Object data) {
        this.success = code.success;
        this.code = code.code;
        this.message = code.message;
        this.data = data;
    }

    public Result(Integer code,String message,boolean success) {
        this.code = code;
        this.message = message;
        this.success = success;
    }

    public static Result SUCCESS(){
        return new Result(ResultCode.SUCCESS);
    }

    public static Result SUCCESS_NO_MESSAGE(){return new Result(ResultCode.SUCCESS_NO_MESSAGE);}

    public static Result SUCCESS_NO_MESSAGE(Object o){
        return new Result(ResultCode.SUCCESS_NO_MESSAGE,o);
    }

    public static Result FAIL(){
        return new Result(ResultCode.FAIL);
    }

}
